package com.digital.smartgrow.controller.expert;

import com.digital.smartgrow.common.advice.Result;
import com.digital.smartgrow.entity.expert.ExpertGroup;
import com.digital.smartgrow.service.expert.ExpertGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 专家组 前端控制器
 * </p>
 *
 * @author sunyuechao
 * @since 2022-07-18
 */
//@Api(tags = "专家组")
//@RestController
//@RequestMapping("${context.prefix}/syc/expertGroup")
public class ExpertGroupController {

    @Autowired
    private ExpertGroupService expertGroupService;
//
//    @ApiOperation(value = "专家组-分页查询")
//    @PostMapping("/list")
//    public Object getListByPage(@RequestBody ExpertGroupPageDTO expertGroupPageDTO){
//        return expertGroupService.getListByPage(expertGroupPageDTO);
//    }

    @ApiOperation(value = "专家组-详情")
    @GetMapping("/{id}")
    public Object getInfo(@PathVariable Integer id){
        if (id == null) return Result.fail("id不能为空");
        return expertGroupService.getInfo(id);
    }

    @ApiOperation(value = "专家组-删除")
    @DeleteMapping("/{id}")
    public Object removeById(@PathVariable Integer id){
      if (id == null) return Result.fail("id不能为空");
      return expertGroupService.removeById(id);
    }
    @ApiOperation(value = "专家组-新增")
    @PostMapping()
    public Object add( @RequestBody ExpertGroup expertGroup){
       return expertGroupService.save(expertGroup);
    }

    @ApiOperation(value = "专家组-编辑")
    @PutMapping()
    public Object edit(@RequestBody ExpertGroup expertGroup){
    if (expertGroup==null||expertGroup.getId() == null)
       return Result.fail("id不能为空");
       return expertGroupService.updateById(expertGroup);
    }
}
